/**
*@author       wuwg
*@createTime   2018/03/20
*@updateTime   2018/03/20
*@description
*@rule
 */
@import '../../../config/config.less';
@import "../form-item/form-item.less";


@css-prefix-radio: ~"@{css-prefix}radio";

.radio-group-error(~"@{css-prefix-form-item}");

.@{css-prefix-radio}-wrapper {
  font-size: @font-size-small;
  vertical-align: middle;
  position: relative;
  white-space: nowrap;
  margin-right: 8px;
  cursor: pointer;
  line-height: 1;
  padding: 10px 0;
  text-align: left;
  display: inline-block;

  &-disabled{
    cursor: @cursor-disabled;
  }

  .@{css-prefix-radio}-inner {
    display: inline-block;
    width: 14px;
    height: 14px;
    position: relative;
    top: 0;
    left: 0;
    background-color: #fff;
    vertical-align:top;
    border: 1px solid @border-color-base;
    border-radius: 50%;
    transition: all @transition-time @ease-in-out;
    &:after {
      position: absolute;
      width: 8px;
      height: 8px;
      left: 2px;
      top: 2px;
      border-radius: @border-radius-base;
      display: table;
      border-top: 0;
      border-left: 0;
      content: ' ';
      background-color: @primary-color;
      opacity: 0;
      transition: all @transition-time @ease-in-out;
      transform: scale(0);
    }
    &:hover {
        border-color: #bcbcbc;
    }
    &-focus {
      box-shadow: 0 0 0 2px fade(@primary-color, 20%);
      z-index: 1;
    }
  }

  .@{css-prefix-radio}-input {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1;
    opacity: 0;
    cursor: pointer;

    &[disabled]{
      cursor: @cursor-disabled;
    }

    & + span {
      display: inline-block;
      height: 14px;
      margin-left: 2px;
      margin-right: 4px;
      line-height: 14px;
      vertical-align: middle;
    }
  }

  // 选中状态
  &-checked {
    .@{css-prefix-radio}-inner {
      border-color: @radio-cheched-color;
      &:after {
        opacity: 1;
        transform: scale(1);
        transition: all @transition-time @ease-in-out;
      }
    }
  }
  // 禁用状态
  &-disabled {
    cursor: @cursor-disabled;

    .@{css-prefix-radio}-inner {
      border-color: @border-color-base;
      background-color: #f3f3f3;
      &:after {
        background-color: #cccccc;
      }
    }

    .@{css-prefix-radio}-input {
      cursor: @cursor-disabled;
      & + span {
        color: #ccc;
        cursor: @cursor-disabled;
      }
    }
  }
}


.@{css-prefix-radio}-group-wrapper {
  font-size: @font-size-small;
  vertical-align: middle;
  border-radius: @btn-border-radius;
  text-align: left;
  padding: 0 10px;
}

// 垂直摆放
.@{css-prefix-radio}-group-vertical {
  .@{css-prefix-radio}-wrapper {
    display: block;
    height: 30px;
    line-height: 30px;
    .@{css-prefix-radio}-inner {
      vertical-align: middle;
    }
  }
}

// 按钮样式
.@{css-prefix-radio}-group-button {
  font-size: 0;
  -webkit-text-size-adjust:none;

  .@{css-prefix-radio}-wrapper {
    display: inline-block;
    height: @btn-circle-size;
    line-height: @btn-circle-size - 2px;
    margin: 0;
    padding: 0 16px - 1px;
    font-size: @font-size-small;
    color: @btn-default-color;
    transition: all @transition-time ease-in-out;
    cursor: pointer;
    border: 1px solid @border-color-base;
    border-left: 0;
    background: #fff;
    position: relative;

    > span {
      margin: 0;
    }

    &:before, &:after {
      content: '';
      display: block;
      position: absolute;
      width: 1px;
      height: 100%;
      left: -1px;
      top: 0;
      background: @border-color-base;
      //visibility: hidden;
      transition: all @transition-time ease-in-out;
    }

    &:after{
      height: @btn-circle-size + 4px;
      left: -1px;
      top: -3px;
      background: fade(@primary-color, 20%);
      opacity: 0;
    }

    &:first-child {
      border-radius: @radio-btn-border-radius 0 0 @radio-btn-border-radius;
      border-left: 1px solid @border-color-base;
      &:before, &:after {
        display: none;
      }
    }

    &:last-child {
      border-radius: 0 @radio-btn-border-radius @radio-btn-border-radius 0;
    }

    &:first-child:last-child {
      border-radius: @radio-btn-border-radius;
    }

    &:hover {
      position: relative;
      color: @primary-color;
      & .@{css-prefix-radio} {
        background-color: black;
      }
    }

    .@{css-prefix-radio}-inner {
      opacity: 0;
      width: 0;
      height: 0;
    }
    // 按钮选中
    &-checked {
      background: @radio-group-button-bg;
      border-color: @primary-color;
      color: @radio-group-button-color;
      box-shadow: -1px 0 0 0 @primary-color;
      z-index: 1;

      &:before{
        background: @primary-color;
        opacity: 0.1;
      }

      &.@{css-prefix-radio}-focus{
        box-shadow: -1px 0 0 0 @primary-color, 0 0 0 2px fade(@primary-color, 20%);
        transition: all @transition-time ease-in-out;
        &:after{
          left: -3px;
          top: -3px;
          opacity: 1;
          background: fade(@primary-color, 20%);
        }
        &:first-child{
          box-shadow: 0 0 0 2px fade(@primary-color, 20%);
        }
      }

      &:first-child {
        border-color: @primary-color;
        box-shadow: none;
      }

      &:hover {
        border-color: tint(@primary-color, 20%);
        //box-shadow: -1px 0 0 0 tint(@primary-color, 20%);
        color: tint(@radio-group-button-color, 20%);
      }

      &:active {
        border-color: shade(@primary-color, 5%);
        //box-shadow: -1px 0 0 0 shade(@primary-color, 5%);
        color: shade(@radio-group-button-color, 5%);
      }
    }

    &-disabled {
      border-color: @border-color-base;
      background-color: @background-color-base;
      cursor: @cursor-disabled;
      color: #ccc;

      &:first-child,
      &:hover {
        border-color: @border-color-base;
        background-color: @background-color-base;
        color: #ccc;
      }
      &:first-child {
        border-left-color: @border-color-base;
      }
    }

    &-disabled.@{css-prefix-radio}-wrapper-checked {
      color: #fff;
      background-color: #e6e6e6;
      border-color: @border-color-base;
      box-shadow: none!important;
    }
  }
}

// radio-group 出错提示样式
.radio-group-error(@class){
    .@{class}-error{
        .@{css-prefix-radio}-group-wrapper {
            border: 1px solid @error-color !important;
        }
    }
}
